<extend name="Layout/ins_page" />
<block name="content">
{:W('PageHeader/simple',array('name'=>'业务权限分配','search'=>'N'))}

<div class="operate panel panel-default">
	<div class="panel-body">
		<div class="pull-right">
			<a onclick="save()"  class="btn btn-sm btn-primary">保存</a>
		</div>
	</div>
</div>
<div class="row">
	<form id="form_data" method="post" action="">
		<div class="col-sm-4 sub_left_menu">
			<table class="table table-bordered">
				<thead>
					<tr>
						<th></th>
						<th>名称</th>
					</tr>
				</thead>
				<tbody>
					<volist name="role_list" id="data">
						<tr id="{$data.id}">
							<td class="col-4"><label class="inline pull-left">
								<input class="ace" type="checkbox" name="role_id[]" value="{$data.id}" />
								<span class="lbl"></span></label></td>
							<td>{$data.name}</td>
						</tr>
					</volist>
				</tbody>
			</table>
		</div>
		<div class="col-sm-8 sub_content">

			<table class="table table-bordered">
				<thead>
					<tr>
						<th>&nbsp;</th>
						<th>名称</th>
						<th>备注</th>
					</tr>
				</thead>
				<tbody>
					<volist name="duty_list" id="data">
						<tr id="{$data.id}">
							<td class="col-4"><label class="inline pull-left ">
								<input class="ace" type="checkbox" id="duty_{$data.id}" name="duty_list[]" value="{$data.id}"/>
								<span class="lbl"></span></label></td>							
							<td class="col-10">{$data.name}</td>
							<td>{$data.remark}</td>
						</tr>
					</volist>
				</tbody>
			</table>
		</div>
	</form>
</div></block>
<block name="js">
<script type="text/javascript">
	function test() {
		form_search.submit();
	};

	function save() {
		sendForm("form_data", "{:U('set_duty')}");
	};

	function showdata(result) {
		$("input[name='duty_list[]']").each(function() {
			$(this).prop('checked', false);
		});
		for (var s in result.data) {
			$("#duty_" + result.data[s].duty_id).prop('checked', true);
		}
	}

	$(document).ready(function() {
		set_return_url();
		$(".sub_left_menu  tr").click(function() {
			$(".sub_left_menu  tr").attr("class", "");
			$(this).attr("class", "active");
			$("#role_id").val($(this).attr("id"));
			sendAjax("{:U('get_duty_list')}", "role_id=" + $(this).attr("id"), function(data) {
				showdata(data);
			});
		});
	}); 
</script>
</block>